import http from '@/utils/request'
import type { PaginationCommon, PaginationRes } from '@/api/common'

/**移动医保 - 开单信息 */
export interface InsurMPayOrderRec {
  orderId: string
  status: number
  source: EnumInsurMPayBusSource
  patientId: string
  name: string
  money: number
  createDate: Date
  items: InsurMPayOrderItem[]
}

/**移动医保 - 明细 */
export interface InsurMPayOrderItem {
  hisOrderId: string
}

/**移动医保 - 业务来源*/
export enum EnumInsurMPayBusSource {
  挂号 = 0,
  门诊 = 1,
  住院 = 2,
}

/**移动医保 - 开单记录查询请求参数 */
export interface GetInsurMPayOrderByPaginationReq extends PaginationCommon {
  beginDate: string
  endDate: string
  inputText: string
}

export const InsurMPayOrderStatusArray = [
  {
    status: '0',
    content: '新增',
    color: '#7aec0fff',
  },
  {
    status: '1',
    content: '发送',
    color: '#41bd10ff',
  },
  {
    status: '2',
    content: '明细提取',
    color: '#198d8dff',
  },
  {
    status: '3',
    content: '医保回写',
    color: '#3d0770ff',
  },
  {
    status: '4',
    content: '结算完成',
    color: '#09008bff',
  },
  {
    status: '5',
    content: '退款完成',
    color: '#0cb490ff',
  },
  {
    status: '9',
    content: '无效',
    color: '#ff0909ff',
  },
]

/**移动医保接口 */
export const InsurMPayAPIs = {
  /**获取订单信息(分页) */
  getOrders(data: GetInsurMPayOrderByPaginationReq) {
    return http.post<PaginationRes<InsurMPayOrderRec>>(`/insurMPay/getOrders`, data)
  },
  /**获取订单信息 */
  getOrder(orderId: string) {
    return http.get<InsurMPayOrderRec>(`/insurMPay/getOrder`, { orderId })
  },
}
